<template>
    <div class="latest-real-time-orders-box">
        <visualTable
            class="container"
            :titleData="titleData"
            :tableData="tableData"
            :pageSize="pageSize"
            :pageNum.sync="pageNum"
            :total="total"
            :isLoading.sync="isLoading"
            @getTable="GetData"
            @sort-change="SortChange"
            ref="tableComp"
        />
    </div>
  </template>
  <script>
    import visualTable from '../../vue/visual-table'
    export default {
        components: { visualTable },
        props: {
            data: {
                type: [Object, Array],
                default: ()=>({})
            }
        },
        data() {
            return {
                total: 20,
                pageNum: 1,
                pageSize: 20,
                isLoading: false,
                titleData: [
                    {
                        label: '门店品牌车型品牌',
                        datakey: 'shop_title_plate_number',
                    },
                    {
                        label: '销售额',
                        datakey: 'payprice',
                        sortable: 'custom',
                    },
                    {
                        label: '下单时间',
                        datakey: 'ctime',
                        sortable: 'custom',
                    },
                ],
                tableData: [],
            }
        },
        watch: {
            // 深度监听对象
            data: {
                handler(newVal, oldVal) {
                    this.GetData()
                },
                deep: true, // 深度监听
                immediate: true // 立即执行一次
            },
        },
        created() {},
        mounted() {
            this.$eventBus.$on('change-Language', this.init);
            this.GetData()
        },
        computed: {},
        methods: {
            init(){
                this.titleData = [
                    {
                        label: this.$t('Byname56'),
                        datakey: 'shop_title_plate_number',
                    },
                    {
                        label: this.$t('Byname58'),
                        datakey: 'payprice',
                        sortable: 'custom',
                    },
                    {
                        label: this.$t('Byname59'),
                        datakey: 'ctime',
                        sortable: 'custom',
                    },
                ]
            },
            // 获取数据信息
            GetData(){
                this.init()
                this.tableData = this.data
            },
            SortChange(item){
                this.$emit('sort-change', item)
            }
        },
    }
  </script>
  <style scoped lang="scss">
    .latest-real-time-orders-box {
        height: 100%;
        height: 100%;
        .container {
            height: 100%;
            margin-bottom: 16px;
        }
    }
  </style>
  